package com.service.base_handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @ClassName FillMetaObjectHandler
 * @Description 自动填充处理器
 * @Author 吃麻椒的花酱
 * @Date 2022/2/9 21:11
 * @Version 1.0
 */
@Component
public class FillMetaObjectHandler implements MetaObjectHandler{

    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime",new Date(),metaObject);
        this.setFieldValByName("editTime",new Date(),metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("editTime",new Date(),metaObject);
    }
}